package delphorm.web.aspect;

import java.lang.reflect.Method;

import javax.servlet.http.HttpServletRequest;

import org.springframework.aop.MethodBeforeAdvice;

import delphorm.web.exception.SecuriteException;


public class VerifierNonAuthentification implements MethodBeforeAdvice, Verif {
	
	public void before(Method method, Object[] arguments, Object target) 
			throws Throwable {
		if(!doVerif(arguments))
			throw new SecuriteException("exception.authentifie");
		
	}
	//true si non authentifié
	public boolean doVerif(Object[] objects) {
		HttpServletRequest request = (HttpServletRequest)objects[0];
		if(request.getSession().getAttribute("utilisateur") != null)
		{
			return false;
		}
		return true;
	}

	

}
